import 'https://cdn.bootcdn.net/ajax/libs/jquery/3.6.0/jquery.min.js';
class left {
    constructor() {

    }
    init() {
        $(function() {
            $(window).on('scroll', function() {
                if ($('html,body').scrollTop() >= 420) {
                    console.log(1);
                    // console.log($('.left-location>ul').attr('display:block'));
                    $('.left-location>ul').css('display', 'block')
                } else {
                    $('.left-location>ul').css('display', 'none')

                }
            })

            // console.log($('html,body').scrollTop());
            $('.left-location>ul>li').on('click', function() {
                let target = $('.' + $(this).attr('data-class'));
                let top = target.offset().top; // 元素距离视口顶部的距离

                $('html,body').animate({
                    scrollTop: top
                }, 600);
            });

            $(window).on('scroll', function() {
                let scrollTop = $(document).scrollTop(); // 获得滚动距离
                let index = Math.round(scrollTop / 697); // 计算出div的索引

                $('.left-location>ul>li').removeClass('active');
                $('.left-location>ul>li:eq(' + index + ')').addClass('active');
            });


        });
    }
}
export {
    left
}
// computer,home-ele,home-pets,clo-shoes,skin-care,eat,jiu,mother,fruits,healthy,life,automobile